package com.holyant.goods.enums;

/**
 * @Auther: holyant
 * @Description: 计算规则枚举
 */
public enum CalSymbolEnum {
    NONE(0,"无"),
    G(10, "大于"),
    GE(20, "大于等于"),
    E(30, "等于"),
    LE(40, "小于等于"),
    L(50, "小于");

    private final Integer code;
    private final String name;

    CalSymbolEnum(Integer code, String name)
    {
        this.code = code;
        this.name = name;
    }

    public Integer getCode()
    {
        return code;
    }

    public String getName()
    {
        return name;
    }

    public static String getNameByCode(Integer code) {
        for (CalSymbolEnum item : CalSymbolEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getName();
            }
        }
        return null;
    }

    public static Integer getCodeByName(String name) {
        for (CalSymbolEnum item : CalSymbolEnum.values()) {
            if (item.getName().equals(name)) {
                return item.code;
            }
        }
        return null;
    }

    public static CalSymbolEnum parse(Integer code) {
        for (CalSymbolEnum item : CalSymbolEnum.values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        return null;
    }

    public static CalSymbolEnum parseByName(String name) {
        for (CalSymbolEnum item : CalSymbolEnum.values()) {
            if (item.getName().equals(name)) {
                return item;
            }
        }
        return null;
    }
}
